home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FAQ.SWG / 0041_SEC18-BORLAND.pas < prev    next >
Pascal/Delphi Source File  |  1995-02-28  |  5KB  |  158 lines

  1. SECTION 18 - Turbo Vision
  2. --------------------------------
  3.  
  4. This document contains information that is most often provided
  5. to users of this section.  There is a listing (when available)
  6. of common Technical Information Documents and example files that
  7. can be downloaded from the libraries, and a listing of the most
  8. frequently asked questions and their answers.
  9.  
  10.  
  11. TECHNICAL INFORMATION DOCUMENTS AND EXAMPLE FILES
  12. -------------------------------------------------
  13.  
  14. TI1721   Determining input focus on Turbo Vision
  15. TI1725   Local Menus in Turbo Vision
  16. TI1729   Simultaneous Dialogs in Turbo Vision 
  17. TI1779   Adding and Removing items from a Turbo Vision Listbox
  18. TI469    Turbo Vision program to go into 132 column mode
  19. TI991    Multiple variations of TInputLine for Turbo Vision
  20. TI993    Use different color combinations in Turbo Vision
  21.  
  22. TVG110.ZIP   Graphics Mode Version of Turbo Vision
  23.  
  24.  
  25. FREQUENTLY ASKED QUESTIONS AND ANSWERS
  26. --------------------------------------
  27.  
  28. Q:   "Can Turbo Vision be run in graphics mode?"
  29.  
  30. A:   Turbo Vision was not designed to support graphics. However,
  31.      there is a file in this library 1 (TVG110.ZIP), which gives
  32.      you a graphics-mode version of Turbo Vision.  There may be
  33.      others uploaded periodically, it's best to search the
  34.      libraries.
  35.  
  36. Q:   "Are there any books that cover Turbo Vision?"
  37.  
  38. A:   Books that cover Turbo Vision are:
  39.  
  40.       "A Programmer Guide to Turbo Vision"
  41.          by Freddy Etrl, Ralph Machholz and Andi Golgath
  42.          Addison-Wesley ISBN 0-201-62401-X
  43.  
  44.       "Turbo Pascal 6.0 Techniques and Utilities"
  45.          by Neil J. Rubenking
  46.          Ziff Davis Press ISBN 1-56276-010-6
  47.  
  48.       "Clean Coding in Turbo Pascal 6"
  49.          by Amrik Dhillon
  50.          M&T Books ISBN 1-55851-228-4
  51.  
  52. Q:   "I don't seem to be getting all the memory used by
  53.      collections after disposing them.  What could be going
  54.      wrong?"
  55.  
  56. A:   If you don't seem to be getting back all your memory when
  57.      disposing of a collection, then there are several things you
  58.      may be doing wrong:
  59.  
  60.      *  You are allocating the collection with 
  61.     
  62.              MyColl := New(PMyColl, init(...))
  63.  
  64.         but are only destroying it with
  65.         
  66.              MyColl^.Done
  67.  
  68.         instead of 
  69.  
  70.              Dispose(MyColl, Done).
  71.  
  72.      *  You have a memory leak in your TObject descendant that
  73.         you are placing in the collection (check your allocations
  74.         in the Init constructor and the deallocs in your Done
  75.         destructor).
  76.  
  77.      *  You are not putting TObject descendants in the
  78.         collection at all (this generally creates program
  79.         crashes.
  80.  
  81.      *  If you call the delete method, the delete method just
  82.         removes the object from the collection but does NOT
  83.         destroy the object, Free removes the object from the
  84.         collection and then destroys it by calling FreeItem
  85.         (which normally calls Dispose(Item, Done)).
  86.  
  87. Q:   "What is the proper way to switch from TVision to graphics
  88.      and back?"
  89.  
  90. A:   For an example you can ook at the DosShell code in APP.PAS
  91.      (or in TVDEMO, if you're using TP6). Follow the same steps,
  92.      but replace the Exec statement with your graphics stuff.
  93.      If you're using TP7/BP7, you may find that you need to
  94.      replace the DoneDosMem/InitDosMem with
  95.      DoneMemory/InitMemory.
  96.  
  97. Q:   "How do you make change the default background of a TVision
  98.      application?"
  99.  
  100. A:   The TBackground object is designed to use only 1 ascii
  101.      character. You could create a new type of background
  102.      object.
  103.  
  104.     Type
  105.        PMyBackground = ^TMyBackground;
  106.        TMyBackground = Object(TView)
  107.          { Variables go here to support your box or text or whatever }
  108.         Procedure Draw; virtual;
  109.         Function GetPalette: PPalette; virtual; { You override this }
  110.          { Other methods here like Load and Store }
  111.        End;
  112.  
  113.     Procedure TMyBackground.Draw;
  114.     Begin
  115.       { Your drawing routine which draws over the whole view }
  116.     End;
  117.  
  118.     
  119.     Also, you will have to override TDesktop.
  120.  
  121.     Type
  122.        PMyDesktop = TMyDesktop;
  123.        TMyDesktop = Object(TDesktop)
  124.         Procedure InitBackground; virtual;
  125.     End;
  126.  
  127.     Procedure TMyDesktop.InitBackground;
  128.     Var
  129.        P: PView;
  130.        R: TRect;
  131.     Begin
  132.        GetExtent(R);
  133.        P := New(PMyBackground, Init(R));
  134.        If ValidView(P) Then
  135.            Insert(P);
  136.     End;
  137.  
  138.     
  139.     You must also override InitDesktop in your main TApplication.
  140.  
  141.     Type
  142.        PMyApp = ^TMyApp;
  143.        TMyApp = Object(TApplication)
  144.         Procedure InitDesktop; virtual;
  145.        End;
  146.  
  147.     Procedure TMyApp.InitDesktop;
  148.     Var
  149.        P: PView;
  150.     Begin
  151.        GetExtent(R);
  152.        Inc(R.A.Y);
  153.        Dec(R.B.Y);
  154.        P := New(PDesktop, Init(R));
  155.        If ValidView(P) Then
  156.            Insert(P);
  157.     End;
  158.